package com.epower.dataobject;

import java.util.Date;
import java.util.List;

import com.epower.base.BaseDO;
import com.epower.bo.epower.commons.Constants;
import com.epower.dao.epoweruserword.EpowerUserWordDAO;
import com.epower.utils.SpringUtils;

public class EpowerBookDO extends BaseDO {

	private static final long serialVersionUID = 1L;

	/**
	 * id
	 */
	private Integer id;

	/**
	 * pid : 父节点的ID
	 */
	private Integer pid;

	/**
	 * sortnum : 排序的方法
	 */
	private Integer sortnum;

	/**
	 * liblevel : è¯¾æœ¬çº§åˆ«
	 */
	private Integer liblevel;

	/**
	 * libname : è¯¾æœ¬å��ç§°
	 */
	private String libname;

	/**
	 * quantity : 课本的单词总数
	 */
	private Integer quantity;

	/**
	 * description : è¯¾æœ¬æ��è¿°
	 */
	private String description;

	/**
	 * type : è¯¾æœ¬ç±»åž‹
	 */
	private Integer type;

	/**
	 * status : 0:æ— æ•ˆ 1:æœ‰æ•ˆ
	 */
	private Integer status;

	/**
	 * createtime
	 */
	private Date createtime;

	/**
	 * updatetime
	 */
	private Date updatetime;

	private int studyNum;

	private int percentage;

	public int getPercentage() {
		this.percentage = this.studyNum * 100 / this.quantity;

		if (percentage == 0 && studyNum != 0) {
			percentage = 1;
		}
		return this.percentage;
	}

	public int getPercentage(Integer userid) {
		this.getStudyNum(userid);
		this.percentage = this.studyNum * 100 / this.quantity;
		if (percentage == 0 && studyNum != 0) {
			percentage = 1;
		}
		return this.percentage;
	}

	public int getPercentage10() {
		int Percentage10 = 0;
		Percentage10 = this.studyNum * 100 / this.quantity;
		if (Percentage10 < 10) {
			Percentage10 = 10;
		} else {
			Percentage10 = (Percentage10 / 10) * 10;
		}
		return Percentage10;
	}

	public void setPercentage(int percentage) {
		this.percentage = percentage;
	}

	public int getStudyNum() {
		return studyNum;
	}

	public int getStudyNum(Integer userid) {
		EpowerUserWordDAO epowerUserWordDAO = (EpowerUserWordDAO) SpringUtils.getBean("epowerUserWordDAO");
		this.studyNum = epowerUserWordDAO.getFamiliarWordCountByBookid(this.id, userid);
		return studyNum;
	}

	public void setStudyNum(int studyNum) {
		this.studyNum = studyNum;
	}

	List<EpowerBookDO> childBookList; // 当前课本的子节点

	public List<EpowerBookDO> getChildBookList() {
		return childBookList;
	}

	public void setChildBookList(List<EpowerBookDO> childBookList) {
		this.childBookList = childBookList;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Integer getPid() {
		return pid;
	}

	public void setPid(Integer pid) {
		this.pid = pid;
	}

	public Integer getSortnum() {
		return sortnum;
	}

	public void setSortnum(Integer sortnum) {
		this.sortnum = sortnum;
	}

	public Integer getLiblevel() {
		return liblevel;
	}

	public void setLiblevel(Integer liblevel) {
		this.liblevel = liblevel;
	}

	public String getLibname() {
		return libname;
	}

	public void setLibname(String libname) {
		this.libname = libname;
	}

	public Integer getQuantity() {
		return quantity;
	}

	public void setQuantity(Integer quantity) {
		this.quantity = quantity;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Integer getType() {
		return type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public Date getCreatetime() {
		return createtime;
	}

	public void setCreatetime(Date createtime) {
		this.createtime = createtime;
	}

	public Date getUpdatetime() {
		return updatetime;
	}

	public void setUpdatetime(Date updatetime) {
		this.updatetime = updatetime;
	}

}
